package com.itheima.tlias.mapper;

import com.github.pagehelper.Page;
import com.itheima.tlias.annotation.MyLog;
import com.itheima.tlias.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * @author
 * @version 1.0.1
 * @date 2023-04-08 10:12:00
 */
@Mapper
public interface EmpMapper {
    /**
     * 根据部门删除员工
     * @param deptId
     */
    @MyLog
    @Delete("delete from emp where dept_id = #{deptId}")
    void deleteByDeptId(Integer deptId);

    @Select("select * from emp where username = #{username} limit 1")
    Emp findByUsername(String username);
    @MyLog
    void update(Emp emp);

    @Select("select * from emp where id = #{id}}")
    Emp findById(Integer id);

    void insert(Emp emp);

    void delete(@Param("ids") List<Integer> ids);


    /**
     * 查询符合条件的总条数
      */
    Long findCount(@Param("name") String name, @Param("gender") Integer gender,
                   @Param("begin") LocalDate begin, @Param("end") LocalDate end);

    /**
     * 查询符合条件的集合
     * @param name
     * @param gender
     * @param begin
     * @param end
     * @param start
     * @param pageSize
     *        limit start, pageSize
     * @return
     */
    List<Emp> findList(@Param("name") String name, @Param("gender") Integer gender,
                       @Param("begin") LocalDate begin, @Param("end") LocalDate end,
                       @Param("start") Integer start, @Param("pageSize") Integer pageSize);

    /**
     * 根据条件查询
     * @param name
     * @param gender
     * @param begin
     * @param end
     * @return
     */
    Page<Emp> findList2(String name, Integer gender, LocalDate begin, LocalDate end);



}
